﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Configuration;

namespace Test
{
    public class Config
    {
        public static string WebServerUrl
        {
            get {
                if (ConfigurationManager.AppSettings["Server"].Equals("remote"))
                    return ConfigurationManager.AppSettings["ServerURL"];
                else
                    return ConfigurationManager.AppSettings["DebugServerURL"];
            }
        }

        public static string DeviceId
        {
            get {
                return ConfigurationManager.AppSettings["DeviceId"];
            }
        }

        public static string GetUrl(string format, params object[] args)
        {
            return WebServerUrl + String.Format(format, args);
        }

        /// <summary>
        /// 获得启动目录
        /// </summary>
        public static string RootPath
        {
            get {
                Config c = new Config();
                string location = c.GetType().Assembly.Location;
                return location.Substring(0,location.LastIndexOf("\\bin\\"));
            }
        }
    }
}
